Predator Prey simulation



 

Java Program







//Written by Brendan Sullivan, Sean Turner
//Written on March 21, 2001
public class PredatorPrey3
/*This program simulates the relationship between predators and prey
using coyotes and rabbits as examples*/
{
public static void main(String [] args)
{
System.out.println("Predator Prey Simulation Model");
System.out.println("Java program");
double num_coyotes=50;
double num_rabbits=200;
int day;
for (day=1; day<=365; day++)
{
System.out.println("day day"+ day);
num_coyotes = num_coyotes-(.10/365);
System.out.println("# coyotes "+ num_coyotes);
num_rabbits = num_rabbits - (.05/365);
System.out.println("# rabbits (after natural causes) "+
num_rabbits);
num_rabbits = num_rabbits + (.07/365);
System.out.println("# rabbits (after births) "+ num_rabbits);
if (num_coyotes>0)
num_rabbits = num_rabbits - (num_coyotes*.02/365);
System.out.println("# rabbits (after eaten) "+ num_rabbits);
if (num_rabbits>0)
num_coyotes = num_coyotes - (.15/num_rabbits/365);
System.out.println("# coyotes (after starvation)"+
num_coyotes);
}
}
}


For More Information E-mail Us At:

Predator Prey simulation